package com.cyl.game.demos.web.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.cyl.game.demos.web.entity.Skin;

@Mapper
public interface SkinMapper {
    // 插入一条皮肤记录
    @Insert("INSERT INTO skins (hero_id, skin_name, skin_description, skin_rarity, skin_price, release_date, is_available, image_url) VALUES (#{hero_id}, #{skin_name}, #{skin_description}, #{skin_rarity}, #{skin_price}, #{release_date}, #{is_available}, #{image_url})")
    int insertSkin(Skin skin);

    // 根据皮肤 ID 查询特定的皮肤信息
    @Select("SELECT * FROM skins WHERE skin_id = #{skin_id}")
    Skin selectSkinById(Integer skin_id);

    // 根据英雄 ID 查询该英雄的所有皮肤信息（方便玩家查看某个英雄有哪些皮肤）
    @Select("SELECT * FROM skins WHERE hero_id = #{hero_id}")
    List<Skin> selectSkinsByHeroId(Integer hero_id);

    // 根据皮肤稀有度查询相应稀有度的所有皮肤（例如查询所有传说皮肤）
    @Select("SELECT * FROM skins WHERE skin_rarity = #{skin_rarity}")
    List<Skin> selectSkinsByRarity(String skin_rarity);

    // 查询所有可用的皮肤（根据 `is_available` 字段判断）
    @Select("SELECT * FROM skins WHERE is_available = 1")
    List<Skin> selectAvailableSkins();

    // 更新皮肤信息（示例，可根据实际需求完善具体更新字段）
    @Insert("UPDATE skins SET hero_id = #{hero_id}, skin_name = #{skin_name}, skin_description = #{skin_description}, skin_rarity = #{skin_rarity}, skin_price = #{skin_price}, release_date = #{release_date}, is_available = #{is_available}, image_url = #{image_url} WHERE skin_id = #{skin_id}")
    int updateSkin(Skin skin);

    // 删除皮肤记录（根据皮肤 ID）
    @Insert("DELETE FROM skins WHERE skin_id = #{skin_id}")
    int deleteSkinById(Integer skin_id);
}